﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;

namespace YArchitech.HVAC
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CommandMark : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication application = commandData.Application;
			Document document = application.ActiveUIDocument.Document;
			FormTotalMarkSetting formTotalMarkSetting = new FormTotalMarkSetting(ShowMarkType.InValid);
			if (formTotalMarkSetting.ShowDialog() == DialogResult.OK)
			{
				MarkOperation markOperation = new MarkOperation();
				Transaction transaction = new Transaction(document, "添加共享参数");
				transaction.Start();
				markOperation.AddAllShareParametes(application);
				markOperation.SetMarkAccuracy(document, formTotalMarkSetting.GetMarkAccuracy());
				markOperation.SetDuctDiameterUnit(document);
				transaction.Commit();
				markOperation.SetActiveDocAllLoadedTags(document, false);
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private PipeInsulationType GetMaterial(Autodesk.Revit.DB.Document doc)
		{
			PipeInsulationType pipeInsulationType = null;
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc);
			filteredElementCollector.OfClass(typeof(PipeInsulationType));
			IEnumerator<Element> elementIterator = filteredElementCollector.GetElementIterator();
			elementIterator.Reset();
			while (elementIterator.MoveNext())
			{
				Element element = elementIterator.Current;
				pipeInsulationType = (element as PipeInsulationType);
				if (pipeInsulationType != null)
				{
					break;
				}
			}
			return pipeInsulationType;
		}

		private void EditHYFamily(Family family, CommonFont commonFont)
		{
		}
	}
}
